<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>


        function get(url, data, async = true, dataType, success) {
            var xhr = new XMLHttpRequest();
            xhr.open("get", url + "?" + data, true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var result = xhr.responseText;
                    if (dataType.toLowerCase() == "json") {
                        result = JSON.parse(result);
                    }
                    if (success) {
                        success(result);
                    }
                }
            }
        }

        function get(url, data, async = true, dataType, success) {
            var xhr = new XMLHttpRequest();
            if (typeof data == "object") {
                var arr = [];
                for (var key in data) {
                    var val = data[key];
                    arr.push(key + "=" + val);
                }
                data = arr.join("&");
            }
            xhr.open("get", url + "?" + data, true);
            xhr.send();
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var result = xhr.responseText;
                    if (dataType.toLowerCase() == "json") {
                        result = JSON.parse(result);
                    }
                    if (success) {
                        success(result);
                    }
                }
            }
        }
        get("../day6/php/html/php/isExist.php", { user: "a12345", pwd: "a12345", phone: "13455555555", email: "123445@qq.com" }, true, "json", function success(result) {
            console.log(result);
        })
    </script>
</body>

</html>